-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Conversation
@jfirebaugh, thanks for your PR! By analyzing the history of the files in this pull request, we identified @kkaefer and @brunoabinader to be potential reviewers. |
Potentially fixes the issues mentioned in #6799 (comment) (needs verification). |
7facf12
to
4b8b19f
Compare
Ready for review! |
74b724e
to
0782253
Compare
@kkaefer The test sources now need the path for generated shader .hpp's in their include paths. Where in the cmake files do I change that? |
You can add |
8cdf2ec
to
8d201ab
Compare
I'd propose adding this to enforce initialization of the primitive types with a value: diff --git a/src/mbgl/gl/draw_mode.hpp b/src/mbgl/gl/draw_mode.hpp
index 8f7db0a..b099a5f 100644
--- a/src/mbgl/gl/draw_mode.hpp
+++ b/src/mbgl/gl/draw_mode.hpp
@@ -11,6 +11,7 @@ public:
using Primitive = Point;
static constexpr std::size_t bufferGroupSize = 1;
+ Points(float pointSize_) : pointSize(pointSize_) {}
float pointSize;
};
@@ -19,6 +20,9 @@ public:
using Primitive = Line;
static constexpr std::size_t bufferGroupSize = 2;
+ Lines(float lineWidth_) : lineWidth(lineWidth_) {
+ assert(lineWidth > 0);
+ }
float lineWidth;
};
@@ -29,6 +33,9 @@ public:
using Primitive = Line;
static constexpr std::size_t bufferGroupSize = 1;
+ LineStrip(float lineWidth_) : lineWidth(lineWidth_) {
+ assert(lineWidth > 0);
+ }
float lineWidth;
};
|
} | ||
}; | ||
|
||
} // namespace mgbl |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What problem does the indexed access solve here? It seems like the code worked before without this as well?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Less verbose --
std::get<typename As::SomeInnerType>(tuple)
becomestuple.template get<As>()
. - Eliminates the need to use a separate helper and
std::index_sequence
inAttributes::binder
. - Will be consistent with use in [core] Properties refactor #6868.
|
||
std::size_t vertexLength; | ||
std::size_t primitiveLength; | ||
std::size_t indexLength; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why switch to indexLength? You're saying "
Segment` now tracks offset and length of indices, rather than primitives. This is more natural.", but I'm unsure what "natural" is supposed to mean.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fundamentally, a vertex/index buffer is a buffer of vertices/indexes, not a buffer of triangles, or lines, or whatever. Conceptually, that's how OpenGL works, and I found it easier to reason about things when I stopped trying to think in terms of buffers of primitives.
Implementation wise, it simplifies calculations like this.
It matches the internal implementation of the new {Vertex,Index}Vector
-- I think if we were to have std::vector<Triangle<Vertex>>
, the packing might come out wrong. You don't want to get in a situation where there might be extra padding every third vertex. {Vertex,Index}Vector
still enforces filling the vector with the right sized groups though.
// | ||
template <class T> void ignore(const std::initializer_list<T>&) {} | ||
|
||
} // namespace mbgl |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we move ignore
to the mbgl::util
namespace to avoid confusion with local variables or mistaking it for a language keyword?
One more thing that I'd like to see (but that is out of scope for this PR) is to somehow move shaders to the context. Background is that for Node.js, we'd like to use a shared context, and ideally we can share the shaders as well to avoid having all of these Programs that are just duplicates. |
b7f71e7
to
f41e21d
Compare
} | ||
}; | ||
} | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we factor out the attributes stuff into its own objects to be in line with the others?
f41e21d
to
aa791f9
Compare
Rebasing this is getting to be a real drag. Can I get this approved and we can follow up on nits in other PRs? |
aa791f9
to
020260d
Compare
Thank you @jfirebaugh - confirming that overdraw debug mode is operational again on Linux: |
…types * Extract `ignore` util to separate header. * `Segment` now tracks offset and length of indices, rather than primitives. This is more natural. * Introduce `VertexVector` and `IndexVector` types. These types carry information about the intended draw mode (`Triangles`, `LineStrip`, etc.), and ensure that elements are always appended in a group size appropriate for that draw mode, for both indexed and unindexed rendering. * `Program`, rather than `Drawable`, is now the unifying object for draw calls. `Program` is the best place to type check the draw call, because it is typed to carry information about the intended primitive, vertex type, attributes, and uniforms. * Use the debug shaders for debug tile rendering, like gl-js. * Fix the draw mode for background. It was drawing triangle strips with a triangles array. Surprised this didn’t cause issues. Now it’s type checked.
020260d
to
3b38cf4
Compare
Followup to #6468, specifically #6468 (comment).